;(function(window, document, $) {
  $.fn.menu = function(options) {
    return this.each(function(ele){
      var menu = $(this);
      var dropdowns = menu.find('.dropdown');
      var menuItems = menu.find('.menu-item');
      dropdowns.on('click', function(event) {
        event.preventDefault();
        event.stopPropagation();
        var menuItem = $($(this).parents('.menu-item')[0]);
        menuItem.toggleClass('open');
      });
      menuItems.on('click', function(event) {
        event.stopPropagation();
        menuItems.removeClass('active');
        $(this).addClass('active');
      });
    });
  }
})(window, document, $)